// JavaScriptyicang

/**********************Proxy公用字符串处理**********************/


//yincang 层 


function openNewDiv(_id) {
            var m = "mask";
            if (docEle(_id)) document.body.removeChild(docEle(_id));
            if (docEle(m)) document.body.removeChild(docEle(m));
            //mask遮罩层
            var newMask = document.createElement("div");
            newMask.id = m;
            newMask.style.position = "absolute";
            newMask.style.zIndex = "998";
            _scrollWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);
            _scrollHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
            newMask.style.width = _scrollWidth + "px";
            newMask.style.height = _scrollHeight + "px";
            newMask.style.top = "0px";
            newMask.style.left = "0px";
            newMask.style.background = "#fffff";
            newMask.style.filter = "alpha(opacity=10)";
            newMask.style.opacity = "0.80";
            document.body.appendChild(newMask);

            //弹出层滚动居中

            function newDivCenter() {
                newDiv.style.top = (document.body.scrollTop + document.body.clientHeight / 2 - newDivHeight / 2) + "px";
                newDiv.style.left = (document.body.scrollLeft + document.body.clientWidth / 2 - newDivWidth / 2) + "px";
            }
            if (document.all) {
                window.attachEvent("onscroll", newDivCenter);
            }
            else {
                window.addEventListener('scroll', newDivCenter, false);
            }

        }
var docEle = function() {
	return document.getElementById(arguments[0]) || false;
	}
function centerPopup(obj) {
	// request data for centering
	var wnd = $(window), doc = $(document);
	var left = doc.scrollLeft();
	var top = doc.scrollTop();
	left += (wnd.width() - obj.width()) / 2;
	top += (wnd.height() - obj.height()) / 2;

	var windowWidth = document.documentElement.clientWidth;
	var windowHeight = document.documentElement.clientHeight;
	var popupHeight = obj.height();
	var popupWidth = obj.width();
	// centering
	obj.css({
				"position" : "absolute",
				"top" : top,
				"left" : left
			});
	// only need force for IE6

	$("#backgroundPopup").css({"height" : windowHeight});
}

// 弹出div层后，将层置于右下角
function rightBottomPopup(obj) {
	// request data for centering
	// centering
	obj.css({
		"position": "absolute",
		"bottom": 0,
		"right": 0
     });
	// only need force for IE6
	obj.slideDown("slow");
	//$("#backgroundPopup").css({"height" : windowHeight});
}

// 加载弹出层
function loadPopup(obj) {
	// loads popup only if it is disabled
	$("#userinfo").css({
				"opacity" : "1"
			});
	$("#userinfo").fadeIn("fast");
	obj.fadeIn("fast");
}
// 隐藏弹出层
function disablePopup(obj) {
	// disables popup only if it is enabled
	$("#userinfo").fadeOut("fast");
	obj.fadeOut("fast");
}

// 去除字符串中空格
String.prototype.TrimAll = function() {
	return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
// 去除字符串中左右空格
String.prototype.Trim = function() {
	return $.trim(this);
}
// 去除字串左空格
String.prototype.LTrim = function() {
	return this.replace(/(^s*)/g, "");
}
// 去除字串中右空格
String.prototype.RTrim = function() {
	return this.replace(/(s*$)/g, "");
}
// 判断是否是空字符串
function isNull(value) {
	if (null==value||value.Trim().length == 0) {
		return true;
	} else {
		return false;
	}
}

// 字符串正则表达式检查
function Check(reg, str) {
	if (reg.test(str)) {
		return true;
	}
	return false;
}

//验证是否有特殊符号
function denotation(str){
	var reg=/[^%&',;=?$\x22]+/;
	if(reg.test(str)){
		return true;
	}else{
		return false;
	}
}

// 只含有汉字、数字、字母、下划线不能以下划线开头和结尾
function charLength(str){
	var reg = /^(?!_)(?!.*?_$)[a-zA-Z0-9_\u4e00-\u9fa5]+$/;
	if(reg.test(str)){
		return true;
	}else{
		return false;
	}
}

//密码只能包含字母、数字
function isPassLength(str){
	var reg=/^[a-zA-Z0-9]{6,12}$/;
	if(reg.test(str)){
		return true;
	}else{
		return false;
	}
}

// 判断是否是Email
function isEmail(mail) {
	var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	return Check(reg, mail);
}

// 判断是否是抄送email地址
function isEmails(mail,no){
	var flag=true;
	var mails=mail.split(",");
 	var length=mails.length;
 	if(length>no){
		flag=false; 
 	}else{
		var f=true;
		for(var i=0;i<length;i++){
			if(!isEmail(mails[i])){
				flag=false;
				break;
			}
		}
	}
  	return flag;
}
// 判读是否是数字
function isInt(value) {
	var reg = /^\d+$/;
	return Check(reg, value);
}
// 判断是否是电话号码
function isPhone(str) {
	if (/^0(([1-9]\d)|([3-9]\d{2}))\d{8}$/.test(str)) {
		return true;
	}
	return false;
}
//哦岸段是否是手机号码
function isMobile(s){
	var reg =/^[1][3,5,4,8][0-9]{9}$/;
	if (reg.test(s)) {
		return true;
	}else{
		return false;
	}
}

//判断是否是传真号码
function isFax(s){
	var reg =/^(([0\+]\d{2,3}-)?(0\d{2,3})-)(\d{7,8})(-(\d{3,}))?$/;
	if (reg.test(s)) {
		return true;
	}else{
		return false;
	}
}

// 判断是否是QQ号码
function isQQ(str) {
	if (/^\d{5,9}$/.test(str)) {
		return true;
	}
	return false;
}

// 判断是否是IP地址
function isIP(str) {
	var reg = /^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/;
	if (reg.test(str)) {
		return true;
	}
	return false;
}

// 判断是否是时间
function isDate(str) {
	var reg = /^((((1[6-9]|[2-9]\d)\d{2})-(0?[13578]|1[02])-(0?[1-9]|[12]\d|3[01]))|(((1[6-9]|[2-9]\d)\d{2})-(0?[13456789]|1[012])-(0?[1-9]|[12]\d|30))|(((1[6-9]|[2-9]\d)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|(((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))-0?2-29-))$/;
	if (reg.test(str)) {
		return true;
	}
	return false;
}
// 判断是否是中文
function isChinese(str)
{
  var str = str.replace(/(^\s*)|(\s*$)/g,'');
  if (!(/^[\u4E00-\uFA29]*$/.test(str)
          && (!/^[\uE7C7-\uE7F3]*$/.test(str))))
  {
      return false;
  }
  return true;
}

// 判断是否是身份证号码
function isIdCardNo(idNumber) {
	var factorArr = new Array(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4,
			2, 1);
	var varArray = new Array();
	var lngProduct = 0;
	var intCheckDigit;

	if ((idNumber.length != 15) && (idNumber.length != 18)) {
		return false;
	}
	for (i = 0; i < idNumber.length; i++) {
		varArray[i] = idNumber.charAt(i);
		if ((varArray[i] < '0' || varArray[i] > '9') && (i != 17)) {
			return false;
		} else if (i < 17) {
			varArray[i] = varArray[i] * factorArr[i];
		}
	}
	if (idNumber.length == 18) {
		var date8 = idNumber.substring(6, 14);
		if (checkDate(date8) == false) {
			return false;
		}
		for (i = 0; i < 17; i++) {
			lngProduct = lngProduct + varArray[i];
		}
		intCheckDigit = 12 - lngProduct % 11;
		switch (intCheckDigit) {
			case 10 :
				intCheckDigit = 'X';
				break;
			case 11 :
				intCheckDigit = 0;
				break;
			case 12 :
				intCheckDigit = 1;
				break;
		}
		if (varArray[17].toUpperCase() != intCheckDigit) {
			return false;
		}
	} else {
		var date6 = idNumber.substring(6, 12);
		if (checkDate(date6) == false) {
			return false;
		}
	}
	return true;
}

//判断表单是否正确，如果不正确则显示错误提示和错误图标
//right or wrong
function doWrongOrRight(obj,str,ico){
	if(str!=null){
		obj.parent().next().find("span.text8").html(str);
	}
	if(ico!=null){
		obj.parent().parent().parent().next(".register-icon,.layer-container-icon").html(ico);
	}else{
		obj.parent().parent().parent().next(".register-icon,.layer-container-icon").html("");
	}
}
//获取url参数
function GetRequest(strName){
 var strHref = window.location.search;
 var intPos = strHref.indexOf("?");
 var strRight = strHref.substr(intPos + 1); 
 var arrTmp = strRight.split("&");
 for(var i = 0; i < arrTmp.length; i++)
 {
  var arrTemp = arrTmp[i].split("=");
  if(arrTemp[0].toUpperCase() == strName.toUpperCase()) return arrTemp[1];
 }
 return "";
}




